class Solution {
public:
    int maxProfit(vector<int>& prices) 
    {
        int ret = 0;
        for(int i = 0, premin = INT_MAX;i < prices.size();i ++)
        {
            ret = max(ret , prices[i] - premin);
            premin = min(prices[i], premin);
        }
        return ret;
    }
};
